<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<script type="text/javascript">
	$(function() {
	//先初始化form表单
		$('#loginForm').form({
			url : 'userAction!save.action',
			success : function(r) {
				//返回的是json字符串，不是json对象，下面两个才是对象
				console.info(r);
				var data =eval("("+r+")");
				console.info(data);
				var obj = jQuery.parseJSON(r);
				console.info(obj.msg);
				
				if (data.success) {
					$('#dd').dialog('close');
				}
				$.messager.show({
					title : '提示',
					msg : obj.msg,
					timeout : 5000,
					showType : 'slide'
				});
			}

		});
	
	
		$('#loginForm input').bind('keyup', function(event) {
			if (event.keyCode == '13') {
				$('#loginForm').submit();
			}
		});
		
	 	//$('#loginForm input[name=username]').focus();//设置自动活校，该方法在火狐有效，在IE中无效，改进如下
	 	window.setTimeout(function(){
	 	$('#loginForm input[name=username]').focus();
	 	},0);
	});
</script>
	<div id="dd" class="easyui-dialog" title="登录"
			style="width:400px;height:200px;"
			data-options="iconCls:'icon-save',resizable:true,closable:false,modal:true,buttons:[{
				text:'注册',
				iconCls:'icon-edit',
				handler:function(){
				$('#regForm input').val('');//或者使用$('#regForm').form('load',{name:'',password:'',repassword:''})
				 $('#regist_dialog').dialog('open');
				}
			},{
				text:'登录',
				iconCls:'icon-help',
				handler:function(){
				$('#loginForm').submit();
				}
			}]">
			<form  method="post" id="loginForm">
			<table style="width: 100%;height: 100%">
				<tr>
					<th align="right">用户名:</th>
					<td><input type="text" name="username" id="username" class="easyui-validatebox" data-options="required:true">
					</td>
				</tr>
				<tr>
					<th align="right">密码:</th>
					<td><input type="password" name="password" id="password" class="easyui-validatebox" data-options="required:true">
					</td>
				</tr>
			</table>
			</form>
		</div>